package code.structure.module.scene.view.iso
{
	/**
	 *墙上壁饰 
	 * @author Yuri
	 * 
	 */
	public class WallMuralIsoObject extends DecorateIsoObject
	{
		private var _attachedWallList:Array;
		
		private var _originalWallList:Array;
		
		public function WallMuralIsoObject()
		{
			super();
			_attachedWallList = [];
			_originalWallList = [];
			isBarrier = false;
			gridIndex = -10;
		}

		/**
		 *涉及的墙壁 
		 */
		public function get attachedWallList():Array
		{
			return _attachedWallList;
		}

		/**
		 * @private
		 */
		public function set attachedWallList(value:Array):void
		{
			dealWallAttach(false);
			_attachedWallList = value;
			dealWallAttach();
		}
		
		/**
		 *处理依附关系 
		 * @param isAttach
		 * 
		 */
		private function dealWallAttach(isAttach:Boolean=true):void{
			var count:int = _attachedWallList.length;
			var i:int = 0;
			var tempWall:WallIsoObject;
			var index:int;
			for(i;i<count;i++){
				tempWall = _attachedWallList[i] as WallIsoObject;
				if(tempWall) {
					index = tempWall.attachedMuralList.indexOf(this);
					if(isAttach){
						if(index==-1)
						tempWall.attachedMuralList.push(this);
					}else{
						if(index!=-1)
						tempWall.attachedMuralList.splice(index,1);
					}
				}
			}
		}
		
		/**
		 * 获取依附墙的ID
		 * @return 
		 * 
		 */
		public function getWallAttachIdList():Array{
			var arr:Array = [];
			var count:int = attachedWallList.length;
			var i:int = 0;
			var tempWall:WallIsoObject;
			for(i;i<count;i++){
				tempWall = _attachedWallList[i] as WallIsoObject;
				if(tempWall) {
					arr.push(tempWall.id);
				}
			}
			return arr;
		}
		
		override public function destroy():void{
			dealWallAttach(false);
			_attachedWallList = [];
			super.destroy();
		}

		/**
		 *原始依附墙壁 为diy取消使用 
		 */
		public function get originalWallList():Array
		{
			return _originalWallList;
		}

		/**
		 * @private
		 */
		public function set originalWallList(value:Array):void
		{
			_originalWallList = value;
		}


	}
}